﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/Site.Master" AutoEventWireup="true" CodeBehind="BorrowData.aspx.cs" Inherits="聚欣订单分析.Borrow.BorrowData" %>

<%@ Register Assembly="DevExpress.Web.v18.1, Version=18.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Data.Linq" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v18.1, Version=18.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        function btnAdd() {
            var btnID = "<%=btnAdd.ClientID%>";
            document.getElementById(btnID).click();
        }

        function btnDel() {
            if (confirm("同时删除物品明细,确认要删除？")) {
                var btnID = "<%=btnDel.ClientID%>";
                document.getElementById(btnID).click();
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH_NAV" runat="server">
    <h2>借货管理</h2>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CPH_Contents" runat="server">
    <div style="display: none;">
        <asp:Button ID="btnAdd" runat="server" Text="新增服务端" OnClick="btnAdd_Click" />
        <asp:Button ID="btnDel" runat="server" Text="删除服务端" OnClick="btnDel_Click" />
    </div>
    <div class="content-page">
        <div class="content">
            <div class="am-g">
                <!-- Row start -->
                <div class="card-box">
                    <div class="am-g" style="padding-bottom: 10px">
                        <div class="am-u-sm-12 am-u-md-6">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">

                                    <button id="btnNew" type="button" class="am-btn am-btn-default" onclick="btnAdd()"><span class="am-icon-plus"></span>新增</button>
                                    <button type="button" class="am-btn am-btn-default" onclick="btnDel()"><span class="am-icon-trash-o"></span>删除</button>
                                </div>
                            </div>
                        </div>

                    </div>
                    <!--.am-form input[type="text"],-->
                    <dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="协议编号" DataSourceID="LinqServerModeDataSource1" Width="100%" AutoGenerateColumns="False" OnRowValidating="ASPxGridView1_RowValidating">
                        <Settings ShowFilterRow="True" />
                        <SettingsDetail ShowDetailRow="true" />
                        <SettingsDetail AllowOnlyOneMasterRowExpanded="true" />
                        <EditFormLayoutProperties ColCount="1"></EditFormLayoutProperties>
                        <Columns>
                            <dx:GridViewCommandColumn Caption="选择" ShowSelectCheckbox="True" VisibleIndex="0" Width="40px">
                            </dx:GridViewCommandColumn>
                            <dx:GridViewDataTextColumn FieldName="协议编号" VisibleIndex="1">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataComboBoxColumn FieldName="借货类型" VisibleIndex="2">
                                <PropertiesComboBox>
                                    <Items>
                                        <dx:ListEditItem Text="测试" Value="测试" />
                                        <dx:ListEditItem Text="项目" Value="项目" />
                                        <dx:ListEditItem Text="维保" Value="维保" />
                                    </Items>
                                </PropertiesComboBox>
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataDateColumn FieldName="借货日期" VisibleIndex="3">
                            </dx:GridViewDataDateColumn>
                            <dx:GridViewDataCheckColumn Caption="长期?" FieldName="长期" VisibleIndex="4">
                                <PropertiesCheckEdit DisplayTextChecked="是" DisplayTextUnchecked="否">
                                </PropertiesCheckEdit>
                            </dx:GridViewDataCheckColumn>
                            <dx:GridViewDataCheckColumn Caption="归转?" FieldName="归还" VisibleIndex="4">
                                <EditFormSettings Visible="False" />
                                <PropertiesCheckEdit DisplayTextChecked="是" DisplayTextUnchecked="否">
                                </PropertiesCheckEdit>
                            </dx:GridViewDataCheckColumn>
                            <dx:GridViewDataComboBoxColumn FieldName="区域" VisibleIndex="5">
                                <PropertiesComboBox>
                                    <Items>
                                        <dx:ListEditItem Text="江苏" Value="江苏" />
                                        <dx:ListEditItem Text="安徽" Value="安徽" />
                                        <dx:ListEditItem Text="山东" Value="山东" />
                                        <dx:ListEditItem Text="湖北" Value="湖北" />
                                    </Items>
                                </PropertiesComboBox>
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataTextColumn FieldName="借货人" VisibleIndex="5">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="用途" VisibleIndex="9">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="备注" VisibleIndex="10">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewCommandColumn ShowClearFilterButton="True" ShowEditButton="True" VisibleIndex="11">
                            </dx:GridViewCommandColumn>
                        </Columns>
                        <SettingsAdaptivity>
                            <AdaptiveDetailLayoutProperties ColCount="1"></AdaptiveDetailLayoutProperties>
                        </SettingsAdaptivity>
                        <Templates>
                            <DetailRow>
                                <dx:ASPxGridView ID="detailGrid" runat="server" KeyFieldName="ID" Width="95%" DataSourceID="SqlDataSource1" OnBeforePerformDataSelect="detailGrid_BeforePerformDataSelect" AutoGenerateColumns="False" OnRowValidating="detailGrid_RowValidating" OnRowInserted="detailGrid_RowInserted" OnRowUpdated="detailGrid_RowUpdated">
                                    <SettingsAdaptivity>
                                        <AdaptiveDetailLayoutProperties ColCount="1">
                                        </AdaptiveDetailLayoutProperties>
                                    </SettingsAdaptivity>
                                    <EditFormLayoutProperties ColCount="1">
                                    </EditFormLayoutProperties>
                                    <Columns>
                                        <dx:GridViewDataTextColumn FieldName="ID" VisibleIndex="0" Visible="false">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="物品" VisibleIndex="1">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataSpinEditColumn FieldName="数量" VisibleIndex="2" UnboundType="Integer">
                                            <PropertiesSpinEdit DisplayFormatString="g" NumberType="Integer">
                                            </PropertiesSpinEdit>
                                        </dx:GridViewDataSpinEditColumn>
                                        <dx:GridViewDataCheckColumn Caption="归还?" FieldName="归还" VisibleIndex="3" Width="60px">
                                            <PropertiesCheckEdit DisplayTextChecked="是" DisplayTextUnchecked="否">
                                            </PropertiesCheckEdit>
                                        </dx:GridViewDataCheckColumn>
                                        <dx:GridViewDataDateColumn FieldName="归还日期" VisibleIndex="4">
                                        </dx:GridViewDataDateColumn>
                                        <dx:GridViewDataTextColumn FieldName="合同号" VisibleIndex="5">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewCommandColumn ShowNewButtonInHeader="True" ShowDeleteButton="true" VisibleIndex="5" Width="50px">
                                        </dx:GridViewCommandColumn>
                                    </Columns>
                                    <SettingsEditing Mode="Batch"></SettingsEditing>
                                </dx:ASPxGridView>
                            </DetailRow>
                        </Templates>
                    </dx:ASPxGridView>
                    <dx:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server" ContextTypeName="聚欣订单分析.Ling.tbl_JHDataContext" DefaultSorting="借货日期 desc" EnableInsert="True" EnableUpdate="false" TableName="tbl_JH" OnInserting="LinqServerModeDataSource1_Inserting" />
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JXDDConnectionString %>" SelectCommand="SELECT * FROM [tbl_JHWP] where 协议编号=@协议编号 ORDER BY ID DESC" InsertCommand="INSERT INTO [tbl_JHWP] (协议编号,物品,数量,归还,归还日期,合同号) VALUES (@协议编号,@物品,@数量,@归还,@归还日期,@合同号)" UpdateCommand="UPDATE [tbl_JHWP] set [归还]=@归还,归还日期=@归还日期,[物品]=@物品,[数量]=@数量,合同号=@合同号 where ID=@ID" DeleteCommand="Delete tbl_JHWP where ID=@ID">
                        <SelectParameters>
                            <asp:SessionParameter Name="协议编号" SessionField="CustomerID" Type="String" />
                        </SelectParameters>
                        <InsertParameters>
                            <asp:SessionParameter Name="协议编号" SessionField="CustomerID" Type="String" />
                            <asp:Parameter Name="物品" />
                            <asp:Parameter Name="数量" />
                            <asp:Parameter Name="归还" DefaultValue="0" />
                            <asp:Parameter Name="归还日期" />
                            <asp:Parameter Name="合同号" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="ID" />
                            <asp:Parameter Name="物品" />
                            <asp:Parameter Name="数量" />
                            <asp:Parameter Name="归还" DefaultValue="0" />
                            <asp:Parameter Name="归还日期" />
                            <asp:Parameter Name="合同号" />
                        </UpdateParameters>
                        <DeleteParameters>
                            <asp:Parameter Name="ID" />
                        </DeleteParameters>
                    </asp:SqlDataSource>
                </div>

            </div>
            <!-- Row end -->
        </div>
    </div>
</asp:Content>
